# 项目:
# 文件: choicetest
# 作者: Yang
# 日期: 2025/5/22 15:18
# coding:utf-8
from time import sleep

import requests
from YDqbtest.tools import Util



def login_session(uname, upass):
    longin_url = Util.read_json('../YDqbtest/conf.json')['longin_url']
    login_data = {'userName': uname, 'userPass': upass, 'checkcode': '0000', 'remember': 'y'}
    session.post(url=longin_url, data=login_data)
    return session

def add_choice():
    add_choice_url = Util.read_json('../YDqbtest/conf.json')['choice_url']
    add_choice_data = Util.read_json('../YDqbtest/conf.json')['choice_data']
    session.post(url=add_choice_url,data=add_choice_data)
    sleep(3)
    query_add_choice = 'select content from exercise order by id desc'
    find_choice = Util.query(query_add_choice)[0][0]
    print(find_choice)

def add_filling():
    add_filling_url = Util.read_json('../YDqbtest/conf.json')['filling_url']
    add_filling_data = Util.read_json('../YDqbtest/conf.json')['filling_data']
    session.post(url=add_filling_url, data=add_filling_data)
    sleep(3)
    query_add_filling = 'select content from exercise order by id desc'
    find_filling = Util.query(query_add_filling)[0][0]
    print(find_filling)

def add_short():
    add_short_url = Util.read_json('../YDqbtest/conf.json')['short_url']
    add_short_data = Util.read_json('../YDqbtest/conf.json')['short_data']
    session.post(url=add_short_url, data=add_short_data)
    sleep(3)
    query_add_short = 'select content from exercise order by id desc'
    find_short = Util.query(query_add_short)[0][0]
    print(find_short)



if __name__ == '__main__':
    session = requests.session()
    login_session('YDXA519','YunDuan123')

    add_choice()
    add_filling()
    add_short()
